add mini_fo patches to mount_root and firstboot
authorMike Baker <[email protected]>
Mon, 17 Apr 2006 19:19:58 +0000 (19:19 +0000)
committerMike Baker <[email protected]>
Mon, 17 Apr 2006 19:19:58 +0000 (19:19 +0000)
SVN-Revision: 3667

openwrt/package/base-files/default/bin/firstboot
openwrt/package/base-files/default/sbin/mount_root

index 44441b0ec0f3fc28adb6ac99582239c51e106541..46106e0e4456dff171b16d5ee45c134c858ec6e7 100755 (executable)
@@ -42,15 +42,25 @@ pivot() { # <new_root> <old_root>
 }
 
 mountdp() { # <device> <mount_point> <ignored> <fs>
-        dev=$1; mnt=$2; shift 2; opt=$*
+       dev=$1; mnt=$2; shift 2; opt=$*
        mount $dev $mnt $opt
        dupe $mnt $rom
        pivot $mnt /rom
 }
 
+fopivot() { # <rw_root> <ro_root> <dupe?>
+       root=$1
+       {
+               mount -t mini_fo -o base=/,sto=$1 none /mnt 2>&- && root=/mnt
+       } || {
+               [ "$3" = "1" ] && mount -o bind $1 $1 && dupe $1 $rom
+       }
+       pivot $root $2
+}
+
 ramoverlay() {
        mkdir -p /tmp/root
-       mountdp /tmp/root /mnt -o bind
+       fopivot /tmp/root /rom 1
 }
 
 [ "${0##*/}" = "firstboot" ] && {
@@ -62,8 +72,8 @@ ramoverlay() {
 
        [ "$1" = "switch2jffs" ] && {
                mtd erase OpenWrt
-               mount -o remount,ro none / # try to avoid fs changing while copying
-               mount -o bind / /mnt
+               mount -o remount,ro none / 2>&- # try to avoid fs changing while copying
+               mount -o bind /tmp/root /mnt
                mount /dev/mtdblock/4 /rom/jffs -t jffs2
                echo -n "copying files ... "
                cp -a /mnt/* /rom/jffs
@@ -71,7 +81,8 @@ ramoverlay() {
                echo "done"
                pivot /rom /mnt
                mount -o move /mnt /tmp/root
-               pivot /jffs /rom
+               fopivot /jffs /rom
+               umount /tmp/root 2>&-
                jffs2root --clean
                exit 0
        }
index 48a9553009d58847d934a2a395edf887cbc5462d..b876907ee902ae2160c13e5599e37f6bdc29d931 100755 (executable)
@@ -24,7 +24,7 @@ if [ "$1" != "failsafe" -a "$(nvram get no_root_swap)" != 1 ]; then
                [ $? != 0 ] && {
                        echo "switching to jffs2"
                        mount /dev/mtdblock/4 /jffs -t jffs2
-                       pivot /jffs /rom
+                       fopivot /jffs /rom
                } || {
                        echo "jffs2 unusable; using ramdisk"
                        ramoverlay